package com.liyuan.help_e.dao;

import com.liyuan.help_e.model.Reply;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ReplyDao {
    @Select("select * from reply where userReceiver = #{id} order by createdAt desc")
    List<Reply> selectRepliesByReceiverId(@Param("id") Integer id);

    @Insert("insert into reply set userReceiver = #{userReceiver},commentId=#{commentId},targetId = #{targetId},type = #{type},createdAt = #{createdAt},status=#{status}")
    void insertReply(Reply reply);

    @Select("select count(*) from reply where userReceiver = #{id} and status = 0")
    Integer sum(@Param("id") Integer id);

    @Update("update reply set status = 1 where id = #{id}")
    void updateReplyStatus(Integer id);
}
